package com.shouer.doc.dialog;

import android.view.Gravity;
import android.widget.Toast;

import com.shouer.doc.R;
import com.shouer.doc.application.App;
import com.shouer.doc.widget.ShouerNotificationToast;

/**
 * Created by ZXL on 2016/12/27.
 */

public class ShouerNotificationToastUtil {

    private App app;
    private static ShouerNotificationToastUtil instance;

    private ShouerNotificationToast notificationToast;

    public static ShouerNotificationToastUtil getInstance(App app) {
        if (instance == null) {
            synchronized (ShouerNotificationToastUtil.class) {
                if (instance == null) {
                    instance = new ShouerNotificationToastUtil(app);
                }
            }
        }
        return instance;
    }

    public ShouerNotificationToastUtil(App app)
    {
        this.app=app;
    }

    public void show(String title,String content)
    {
        if (null!=notificationToast)
        {
            notificationToast.cancel();
            notificationToast.setContent(content);
            notificationToast.setTitle(title);
            notificationToast.setTime();
            notificationToast.show();
        }else
        {
            ShouerNotificationToast.Builder builder = new ShouerNotificationToast.Builder(app);
            builder.setContent(content)
                    .setTitle(title)
                    .setDuration(Toast.LENGTH_SHORT)
                    .setGravity(Gravity.TOP | Gravity.FILL_HORIZONTAL)
                    .setmView(R.layout.layout_heads_up_notification);
            builder.createToast().show();
        }
    }

}
